package org.urbansoft.icl.record;

import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.urbansoft.icl.field.Field;
import org.urbansoft.icl.field.GenericANField;
import org.urbansoft.icl.field.Position;
import org.urbansoft.icl.field.validation.RecordTypeValidator;

/**
 * 
 * @author Ricardo Reyes
 */
public class ReturnAddendumD3599 extends Record {

	static Logger log = Logger.getLogger(BundleControlRecord.class);

	public Field recordType;
	public Field recordNumber;
	public Field endBankRoutingNumber;
	public Field endBankEndDate;
	public Field endBankItemSequenceNumber;
	public Field truncationIndicator;
	public Field endBankConvIndicator;
	public Field endBankCorrIndicator;
	public Field returnReason;
	public Field userField;
	public Field endBankIdentifier;
	public Field reserved;

	/* contructor for read purposes */
	public ReturnAddendumD3599() {
		// log.info("New ReturnAddendumD3599 ");
		fields = new ArrayList<Field>();
		recordName = "Return AddendumD 35-99";
		recordTypeNumber = "35";
		initFields2();
	}

	/* contructor for write purposes */
	public ReturnAddendumD3599(int dummy) {
		fields = new ArrayList<Field>();
		recordName = "Return AddendumD 35-99";
		recordTypeNumber = "35";
		initFields();
	}

	/**
	 * Inits the fields for read.
	 */
	private void initFields() {
		try {
			/* check detail record */

			recordType = new GenericANField(new Position(1, 2),
					RecordTypeValidator.INSTANCE, "35", "Record Type");

			/* recordNumber es 01 */
			recordNumber = new GenericANField(new Position(3, 4),
					"Record Number");
			recordNumber.setFieldData("99");

			/* accountHolderName */
			endBankRoutingNumber = new GenericANField(new Position(5, 13),
					"Endorsing Bank Routing Number");
			endBankRoutingNumber.setFieldData("");

			/* endBankEndDate */
			endBankEndDate = new GenericANField(new Position(14, 21),
					"Endorsing Bank Endorsement Date");
			endBankEndDate.setFieldData("");

			/* endBankItemSequenceNumber */
			endBankItemSequenceNumber = new GenericANField(
					new Position(22, 36), "Endorsing Bank Item Sequence Number");
			endBankItemSequenceNumber.setFieldData("");

			/* truncationIndicator */
			truncationIndicator = new GenericANField(new Position(37, 37),
					"Truncation Indicator");
			truncationIndicator.setFieldData("");

			/* endBankConvIndicator */
			endBankConvIndicator = new GenericANField(new Position(38, 38),
					"Endorsing Bank Conversion Indicator");
			endBankConvIndicator.setFieldData("");

			/* endBankCorrIndicator */
			endBankCorrIndicator = new GenericANField(new Position(39, 39),
					"Endorsing Bank Correction Indicator");
			endBankCorrIndicator.setFieldData("");

			/* returnReason */
			returnReason = new GenericANField(new Position(40, 40),
					"Return Reason");
			returnReason.setFieldData("");

			/* userField */
			userField = new GenericANField(new Position(41, 59), "User Field");
			userField.setFieldData("");

			/* endBankIdentifier */
			endBankIdentifier = new GenericANField(new Position(60, 60),
					"Endorsing Bank Identifier");
			endBankIdentifier.setFieldData("");

			/* reserved */
			reserved = new GenericANField(new Position(61, 90), "Reserved");
			reserved.setFieldData("");

			fields.add(recordType);
			fields.add(recordNumber);
			fields.add(endBankRoutingNumber);
			fields.add(endBankEndDate);
			fields.add(endBankItemSequenceNumber);
			fields.add(truncationIndicator);
			fields.add(endBankConvIndicator);
			fields.add(endBankCorrIndicator);
			fields.add(returnReason);
			fields.add(userField);
			fields.add(endBankIdentifier);
			fields.add(reserved);

		} catch (Exception e) {
			log.fatal(e.getMessage(), e);
		}
	}

	/* Register for read only purposes */
	private void initFields2() {
		try {
			/* check detail record */

			recordType = new GenericANField(new Position(1, 2),
					RecordTypeValidator.INSTANCE, "35", "Record Type");

			/* recordNumber es 01 */
			recordNumber = new GenericANField(new Position(3, 4),
					"Record Number");

			/* accountHolderName */
			endBankRoutingNumber = new GenericANField(new Position(5, 13),
					"Endorsing Bank Routing Number");

			/* endBankEndDate */
			endBankEndDate = new GenericANField(new Position(14, 21),
					"Endorsing Bank Endorsement Date");

			/* endBankItemSequenceNumber */
			endBankItemSequenceNumber = new GenericANField(
					new Position(22, 36), "Endorsing Bank Item Sequence Number");

			/* truncationIndicator */
			truncationIndicator = new GenericANField(new Position(37, 37),
					"Truncation Indicator");

			/* endBankConvIndicator */
			endBankConvIndicator = new GenericANField(new Position(38, 38),
					"Endorsing Bank Conversion Indicator");

			/* endBankCorrIndicator */
			endBankCorrIndicator = new GenericANField(new Position(39, 39),
					"Endorsing Bank Correction Indicator");

			/* returnReason */
			returnReason = new GenericANField(new Position(40, 40),
					"Return Reason");

			/* userField */
			userField = new GenericANField(new Position(41, 59), "User Field");

			/* endBankIdentifier */
			endBankIdentifier = new GenericANField(new Position(60, 60),
					"Endorsing Bank Identifier");
			endBankIdentifier.setFieldData("");

			/* reserved */
			reserved = new GenericANField(new Position(61, 90), "Reserved");

			fields.add(recordType);
			fields.add(recordNumber);
			fields.add(endBankRoutingNumber);
			fields.add(endBankEndDate);
			fields.add(endBankItemSequenceNumber);
			fields.add(truncationIndicator);
			fields.add(endBankConvIndicator);
			fields.add(endBankCorrIndicator);
			fields.add(returnReason);
			fields.add(userField);
			fields.add(endBankIdentifier);
			fields.add(reserved);

		} catch (Exception e) {
			log.fatal(e.getMessage(), e);
		}
	}

}
